<?php

use yii\helpers\Html;

use app\base\misc\adminlte\ActiveForm;
use app\attachment\widgets\SingleMediaWidget;
use addons\revolutionslider\assets\RevolutionsliderAsset;
use yii\helpers\Url;

RevolutionsliderAsset::register($this);

$form = ActiveForm::begin([
    'options' => [
        'enctype' => 'multipart/form-data',
        'class' => 'model-form'
    ]
]);
?>

<div class="row">
    <div class="col-md-6">

        <?php
        echo $form->boxField($model, 'thumbnail')
            ->widget(SingleMediaWidget::className())
            ->header("幻灯图片");
        ?>

        <?= Html::submitButton($model->isNewRecord ? '发布' : '更新', ['class' => 'btn bg-maroon btn-flat margin-bottom btn-block']) ?>
    </div>
    <div class="col-md-6">
        <div id="caption-list">
            <?php if (!empty($model->captions)): ?>
                <?php foreach ($model->captions as $index => $caption): ?>
                    <?php echo $this->render("_caption", ["model" => $caption, 'index' => $index]) ?>
                <?php endforeach; ?>
            <?php endif; ?>
        </div>
        <?= Html::button('添加文字', ['class' => 'btn bg-maroon btn-flat margin-bottom btn-block', "id" => "addCaption", "data-url" => Url::to(["addcaption"])]) ?>
    </div>
</div>


<?php ActiveForm::end(); ?>
